package util;

import java.io.UnsupportedEncodingException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {

	public static boolean chk(String regex, String s) {
		if (s == null || s.trim().length() < 0) {
			return false;
		} else {
			Pattern p = Pattern.compile(regex);
			Matcher m = p.matcher(s.trim());
			return m.find();
		}
	}

	public static String converToUTF8(String s) {
		String str = null;
		try {
			str = new String(s.getBytes("UTF-8"));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return str;

	}

	public static String getTime(int t) {
		int s = t % 60;
		int m = (t % 3600) / 60;
		int h = t / 3600;
		return (new StringBuilder(String.valueOf(h))).append(":").append(m)
				.append(":").append(s).toString();
	}
}
